<?php

/*
+--------------------------------------------------------------------------
|   Invision Power Board
|   =============================================
|   by Matthew Mecham
|   (c) 2001 - 2006 Invision Power Services, Inc.
|   http://www.invisionpower.com
|   =============================================
|   Web: http://www.invisionboard.com
|   Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|   > $Date: 2009-07-27 18:46:08 +0000 (Mon, 27 Jul 2009) $
|   > $Revision: 135 $
|   > $Author: supersmashbrothers $
+---------------------------------------------------------------------------
|
|   > Settings Plug In
|   > Module written by Matt Mecham
|   > Date started: 27th September 2006
|
+--------------------------------------------------------------------------
*/

/**
* Main content
*
*/

if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
	exit();
}

class setting_ibmarket
{
	/**
	* Global IPSCLASS
	* @var	object
	*/
	var $ipsclass;
	
	function settings_pre_parse( $settings=array() ) 
	{
		foreach( $settings as $id => $data )
		{
			if ( $data['conf_key'] == 'market_members_field' )
			{
				$settings[$id]['conf_description'] = str_replace("<#SQL_PREFX#>", SQL_PREFIX, $settings[$id]['conf_description']);
				
				require_once(ROOT_PATH."sources/market/sql/".$this->ipsclass->vars['sql_driver']."_acp_settings.php");
				$generate = new sql_market_settings();
				$generate->ipsclass =& $this->ipsclass;
				$generate->no_fields = array('mgroup', 'joined', 'dst_in_use', 'allow_admin_mails','email_pm', 'email_full', 'skin', 'warn_level', 'warn_lastwarn', 'last_post', 'view_sigs', 'view_img', 'view_avs', 'view_pop', 'bday_day', 'bday_month', 'bday_year', 'new_msg', 'msg_total', 'show_popup', 'last_visit', 'last_activity', 'coppa_user', 'sub_end', 'member_login_key_expire', 'subs_pkg_chosen', 'has_blog', 'has_gallery', 'members_auto_dst', 'members_created_remote', 'members_disable_pm', 'failed_login_count', 'members_profile_views');
				$fields = $generate->generate_columns();
				
				foreach($fields as $field => $display)
				{
					$settings[$id]['conf_extra'] .= $field."=".$display."\n";
				}
				
				rtrim($settings[$id]['conf_extra']);
			}
		}
		
		return $settings;
	}
	
	function settings_post_parse( $settings=array() ) 
	{
		foreach( $settings as $data )
		{
			if ( $data['conf_key'] == 'market_name' )
			{
				$value = $data['_value'] ? $data['_value'] : $data['conf_default'];
				$this->ipsclass->DB->do_update('components',array('com_url_title'=>$value),"com_section='market'");
				
				require_once( ROOT_PATH.'sources/action_admin/components.php' );
				$components           = new ad_components();
				$components->ipsclass =& $this->ipsclass;
				
				$components->components_rebuildcache();
			}
		}
		
		return $settings;
	}
	
}


?>